<?php
/*
Plugin Name: 评论表情插件
Version: 1.0
Plugin URL:http://www.sprityaoyao.com
Description: 为评论添加表情功能
Author: sprityaoyao
Author Email: 13919361718.cool@163.com
Author URL: http://www.sprityaoyao.com
*/
!defined('EMLOG_ROOT') && exit('access deined!');

function face() {
?>
<script src="<?php echo BLOG_URL;?>include/lib/js/jquery/jquery-1.2.6.js"></script>
<script type="text/javascript">
var a = false, blog_url = "<?php echo BLOG_URL; ?>";
$(function(){
	$("textarea[name=comment]").focus(function() {
		if (!a) {
			$.getScript(blog_url + "content/plugins/face/smile.js");
			a = true;
		}
	});
});
</script>
<?php
}
addAction('index_head', 'face');
function face_replace() {
	$output = ob_get_clean();
	$output = preg_replace("|\{smile:(\d+)\}|i",'<img src="' . BLOG_URL . 'content/plugins/face/face/$1.gif" />',$output);
	ob_start();
	echo $output;
}
addAction('index_footer','face_replace');